﻿using BUS;
using DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace nhakhoachauau
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        public decimal TongPhiDieuTri, TongPhiThanhToan, TongPhiConNo;
        public int SLBNNo;
        protected void Page_Load(object sender, EventArgs e)
        {
            TongPhiThanhToan = TongPhiDieuTri = TongPhiConNo = 0;
            LoadDanhSachNo();
        }

        private void LoadDanhSachNo()
        {
            Q_BUSBenhNhan BUSbn = new Q_BUSBenhNhan();
            List<BenhNhanNoPhi> dsNoPhi = BUSbn.dsBenhNhanNoPhi();
            if (dsNoPhi == null)
                dsNoPhi = new List<BenhNhanNoPhi>();
            rptDanhSachNo.DataSource = dsNoPhi;
            rptDanhSachNo.DataBind();
            SLBNNo = dsNoPhi.Count;
        }

        protected void rptDanhSachNo_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                BenhNhanNoPhi BNno = (BenhNhanNoPhi)e.Item.DataItem;
                Label lblSTT = (Label)e.Item.FindControl("lblSTT");
                Label lblBenhNhan = (Label)e.Item.FindControl("lblBenhNhan");
                Label lblSoHoSo = (Label)e.Item.FindControl("lblSoHoSo");
                Q_BUSBenhNhan BUSbn = new Q_BUSBenhNhan();
                BenhNhan bn = BUSbn.ThongTinBenhNhan(BNno.ID_BenhNhan);
                lblBenhNhan.Text = bn.ho_ten;
                lblSoHoSo.Text = bn.so_ho_so.ToString();
                TongPhiDieuTri += BNno.TongTienThanhToan;
                TongPhiThanhToan += BNno.TongTienDaThanhToan;
                TongPhiConNo += BNno.TongTienConNo;
                lblSTT.Text = (e.Item.ItemIndex + 1).ToString();
            }
        }
    }
}